jQuery(document).ready(function() { 	
	
	//------------- Check all checkboxes  -------------//
	
	jQuery("#masterCh").click(function() {
		var checkedStatus = jQuery(this).find('span').hasClass('checked');
		jQuery("#checkAll tr .chChildren input:checkbox").each(function() {
			this.checked = checkedStatus;
				if (checkedStatus == this.checked) {
					jQuery(this).closest('.checker > span').removeClass('checked');
				}
				if (this.checked) {
					jQuery(this).closest('.checker > span').addClass('checked');
				}
		});
	});
});

function multiple_action(action, url) {
	var ids = "";
	jQuery(".table tbody tr td input[type=checkbox]").each(function (item, data) {
		if (jQuery(this).is(':checked')) {
			ids += jQuery(this).val() + ",";
		}
	});
	showAjaxEffect();
	jQuery.get(url, {ids: ids, action: action}, function(data) {
		hideAjaxEffect();
		notify("success", "Update success.", "Your data change success.");
		location.reload();
	});
}

function showAjaxEffect() {
	jQuery(".title .loader").removeClass("hide");
}

function hideAjaxEffect() {
	jQuery(".title .loader").addClass("hide");
}

/**
 * Notify
 * @param type: success, error, info
 * @param msg
 */
function notify(type, title, content) {
	jQuery.pnotify({
		type: type,
	    title: title,
		text: content,
	    icon: 'picon icon16 iconic-icon-check-alt white',
	    opacity: 0.95,
	    hide:false,
	    history: false,
	    sticker: false
	});
}